package com.csw.android.player.service

import android.app.Activity
import android.os.Bundle
import com.csw.android.player.PlayerManager
import com.csw.android.player.ui.full.FullScreenPlayActivity
import com.csw.android.player.view.window.VideoFloatWindow

/**
 * 通知点击 通过PendingIntent.getActivity打开Activity时，才会收起通知栏
 * 这个Activity要在新的栈中打开，并关闭，这样finish才不会返回App已经打开的界面
 */
class CloseNotificationBarActivity : Activity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        actionBar?.hide()
        super.onCreate(savedInstanceState)
        when (intent.action) {
            PlayService.ACTION_NOTIFICATION_CLICK -> {
//                MainActivity.openActivity(this)
            }

            PlayService.ACTION_PLAY_NEXT -> PlayerManager.SINGLE_PLAYER.playList?.playNext()
            PlayService.ACTION_PLAY_PREVIOUS -> PlayerManager.SINGLE_PLAYER.playList?.playPrevious()
            PlayService.ACTION_PLAY_CURR -> PlayerManager.SINGLE_PLAYER.playList?.playCurrent()
            PlayService.ACTION_PAUSE_CURR -> PlayerManager.SINGLE_PLAYER.pause()
            PlayService.ACTION_FULL_SCREEN -> FullScreenPlayActivity.open(
                this,
                PlayerManager.SINGLE_PLAYER.playId,
                null
            )

            PlayService.ACTION_FLOAT_WINDOW -> VideoFloatWindow.instance.run {
                show()
                startPlay(PlayerManager.SINGLE_PLAYER.playId)
            }
        }
        finish()
    }

}